package com.zerosoft.shuguang.config;

import com.zerosoft.shuguang.dao.GuotaiEventParse;
import com.zerosoft.shuguang.service.MqttAcceptClient;
import jakarta.annotation.Resource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MqttConfig {
    @Resource
    private MqttAcceptClient mqttAcceptClient;

    /**
     * 订阅mqtt
     *
     * @return
     */
    @Conditional(MqttCondition.class)
//    @Bean
    public MqttAcceptClient getMqttPushClient() {
        System.out.println("MqttAcceptClient init");

        GuotaiEventParse guotaiEventParse = new GuotaiEventParse();
        guotaiEventParse.setEventType(GuotaiEventParse.TYPE_PART);
        guotaiEventParse.setDeviceType(GuotaiEventParse.TYPE_LOOP);
        guotaiEventParse.setMachine("loop");
        guotaiEventParse.setPosition("loop");
        guotaiEventParse.setDescription("loop");
        guotaiEventParse.setEventNumber("loop");
        guotaiEventParse.setPanelTypeName("loop");
        guotaiEventParse.setRoad("loop");
        guotaiEventParse.setBuild("loop");
        guotaiEventParse.setPartTypeName("loop");
        System.out.println(guotaiEventParse.parseJson());

        mqttAcceptClient.connect();
//        mqttAcceptClient.subscribe("/shuguang/save", 0);
        return mqttAcceptClient;
    }
}
